{% block sw_license_violation %}
<sw-modal
    v-if="visible"
    :title="$tc('sw-license-violation.title')"
    :closable="false"
    variant="large"
    class="sw-license-violation"
    :is-loading="isLoading"
>

    <span class="sw-license-violation__text">
        {{ $tc('sw-license-violation.alertText') }}
    </span>

    <table class="sw-license-violation__table">
        <thead>
            <tr>
                <th width="200px">
                    {{ $tc('sw-license-violation.table.plugin') }}
                </th>
                <th>{{ $tc('sw-license-violation.table.warning') }}</th>
                <th width="350px"></th>
            </tr>
        </thead>
        <tbody>
            <tr
                v-for="violation in violations"
                :key="violation.name"
            >
                <td class="sw-license-violation__table-name">
                    <template v-if="getPluginForViolation(violation)">
                        <img
                            v-if="getPluginForViolation(violation).icon || getPluginForViolation(violation).iconRaw"
                            :src="'data:image/png;base64, ' + (getPluginForViolation(violation).iconRaw || getPluginForViolation(violation).icon)"
                            alt=""
                        >
                        <strong>
                            {{ (getPluginForViolation(violation).translated && getPluginForViolation(violation).translated.label) || getPluginForViolation(violation).label}}
                        </strong>
                    </template>

                    <template v-else>
                        <p>
                            <strong>{{ violation.name }}</strong>
                        </p>
                    </template>
                </td>

                <td>{{ violation.extensions.licenseViolation.text }}</td>

                <td class="sw-license-violation__table-actions">
                    <div
                        v-for="action in violation.extensions.licenseViolation.actions"
                        :key="action.externalLink"
                        class="sw-license-violation__table-actions-wrap"
                    >
                        <mt-button
                            class="sw-license-violation__table-action-remove"
                            variant="critical"
                            ghost
                            size="small"
                            @click.prevent="deletePlugin(violation)"
                        >
                            {{ $tc('sw-license-violation.deletePlugin') }}
                        </mt-button>

                        <mt-button
                            :link="action.externalLink"
                            ghost
                            size="small"
                            variant="secondary"
                        >{{ action.label }}
                        </mt-button>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>

    <template #modal-footer>
        <mt-checkbox
            v-model:checked="readNotice"
            :label="$tc('sw-license-violation.checkboxMessage')"
        />

        <mt-button
            variant="primary"
            :disabled="!readNotice"
            size="small"
            @click="deactivateTemporary"
        >
            {{ $tc('sw-license-violation.closeModal') }}
        </mt-button>
    </template>

    <sw-modal
        v-if="showDeleteModal"
        :title="$tc('sw-license-violation.title')"
        class="sw-license-violation-confirm-delete"
        variant="small"
        @modal-close="onCloseDeleteModal"
    >

        <p class="sw-plugin-list__confirm-delete-text">
            {{ $tc('sw-license-violation.messageDeleteConfirm', { pluginName: deletePluginItem.label }) }}
        </p>

        <template #modal-footer>
            <mt-button
                size="small"
                variant="secondary"
                @click="onCloseDeleteModal"
            >
                {{ $tc('global.default.cancel') }}
            </mt-button>

            <mt-button
                size="small"
                variant="critical"
                @click="onConfirmDelete"
            >
                {{ $tc('global.default.delete') }}
            </mt-button>
        </template>
    </sw-modal>
</sw-modal>
{% endblock %}
